<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%@page import="iwpl.project.entities.Departments"%>
<%@page import="iwpl.project.entities.Areas"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@page import="iwpl.project.dao.*"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'test.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	
	
	
	<script language="javascript" src="js/prototype-1.6.0.2.js" type="text/javascript"></script>
	
	<script language="javascript" type="text/javascript">
        function loadDataFromServer() {
            var data = $('cbodepart').value;
            var url = "/DepartmentManage/servlet/Control_Contract?action=ajax&&id="+data;
            var params = "id=" + data;
            new Ajax.Updater("divData",
                url,
                {method: 'post', parameters: params, onComplete: doOnComplete, onFailure: doOnFailure, evalScripts: true});
        }
        function loadDataFromServer1() {
            var data = document.getElementById("idSelect1").value;
            var url = "PrototypeServer.aspx";
            var params = "id=" + data;
            new Ajax.Updater("divData1",
                url,
                {method: 'post', parameters: params, onComplete: doOnComplete, onFailure: doOnFailure, evalScripts: true});
        }
        function doOnComplete() {}        
        function doOnFailure() {}        
    </script>
    
    
  </head>
  
  <body>
    	<table>
    		<tr>
    			<td>
    				<% 
    					DepartmentsDAO dao = new DepartmentsDAO();
						List<Departments> list = dao.findAll();
						Departments dp=new Departments();
						Iterator ir=list.listIterator();
						out.print("<select id=cbodepart onchange=loadDataFromServer();>");
						while(ir.hasNext())
						{
							dp=(Departments)ir.next();
							int id=dp.getId();
							//Areas areaid=(Areas)dp.getAreases();
							String name=dp.getDepartmentName();
							out.print("<option value="+id+">"+name+"</option>");
						}
						out.print("</select>")	;		

									
    				%>
    				<div id="divData"></div>
    			</td>
    		</tr>
    	</table>
  </body>
</html>
